<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<link rel="stylesheet" type="text/css" href="../layui/css/layui.css" media="all" />
	</head>
	<body style="padding: 10px;">
		<form class="layui-form layui-form-pane" action="" lay-filter="formUpdateCustomer">
			<input type="hidden" name="cusNo" /><!-- 隐藏窗口的客户编号 -->
			<div class="layui-form-item">
				<label class="layui-form-label">客户名称</label>
				<div class="layui-input-block">
					<input type="text" name="cusName" placeholder="请输入客户名称" class="layui-input" lay-verify='required'>
				</div>
			</div>
			<div class="layui-form-item">
			    <label class="layui-form-label">所在地</label>
			    <div class="layui-input-block">
			      <select name="cusRegion" lay-verify='required'>
			        <option value="">请选择</option>
			        <option value="1">东北</option>
			        <option value="2">西北</option>
			        <option value="3">华北</option>
			        <option value="4">华中</option>
			        <option value="5">华南</option>
			        <option value="6">西南</option>
			        <option value="7">华东</option>
			      </select>
			    </div>
			</div>
			<div class="layui-form-item">
			    <label class="layui-form-label">客户等级</label>
			    <div class="layui-input-block">
			      <select name="cusLevel" lay-verify='required'>
					//客户等级(1-战略合作伙伴、2-合作伙伴、3-大客户、4-重点开发客户、5-普通客户、6-VIP客户)
			        <option value="">请选择</option>
			        <option value="1">战略合作伙伴</option>
			        <option value="2">合作伙伴</option>
			        <option value="3">大客户</option>
			        <option value="4">重点开发客户</option>
					<option value="5">普通客户</option>
					<option value="6">VIP客户</option>
			      </select>
			    </div>
			</div>
			<div class="layui-form-item">
			    <label class="layui-form-label">客户信用度</label>
			    <div class="layui-input-block">
			      <select name="cusCredit" lay-verify='required'>
			        <option value="">请选择</option>
			        <option value="1">一级</option>
			        <option value="2">二级</option>
			        <option value="3">三级</option>
			        <option value="4">四级</option>
					<option value="5">五级</option>
			      </select>
			    </div>
			</div>
			<div class="layui-form-item">
			    <label class="layui-form-label">客户满意度</label>
			    <div class="layui-input-block">
			      <select name="cusSatisfaction" lay-verify='required'>
			        <option value="">请选择</option>
			        <option value="1">一级</option>
			        <option value="2">二级</option>
			        <option value="3">三级</option>
			        <option value="4">四级</option>
			        <option value="5">五级</option>
			      </select>
			    </div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">网址</label>
				<div class="layui-input-inline">
					<input type="text" name="cusUrl" placeholder="请输入网址" autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
			    <label class="layui-form-label">客户状态</label>
			    <div class="layui-input-block">
			      <select name="cusState" lay-verify='required'>
			        <option value="">请选择</option>
			        <option value="1">正常</option>
			        <option value="0">不正常</option>
			      </select>
			    </div>
			</div>
			<div class="layui-form-item">
				<div class="layui-input-block">
					<button type="submit" class="layui-btn" lay-submit="" lay-filter="submitUpdateCustomer">立即修改</button>
					<button type="reset" class="layui-btn layui-btn-primary">重置</button>
				</div>
			</div>
		</form>
		<script src="../layui/layui.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			layui.use(['form', 'jquery'], function() {
				var form = layui.form;
				var $ = layui.jquery;
				// formUpdateCustomer是form的lay-filter的属性的值
				form.val('formUpdateCustomer', {
					"cusName": parent.row.cusName,
					"cusNo": parent.row.cusNo,
					"cusRegion": parent.row.cusRegion,
					"cusLevel": parent.row.cusLevel,
					"cusCredit": parent.row.cusCredit,
					"cusSatisfaction": parent.row.cusSatisfaction,
					"cusUrl": parent.row.cusUrl,
					"cusState": parent.row.cusState,
				});
				
			 //监听提交
			form.on('submit(submitUpdateCustomer)', function(d){
				// d.field //表单的数据
				if (form.verify()){
					$.ajax({
						url:'http://localhost:8080/customer/updateCustomer',
						type:'POST',  //提交方式，有POST、GET等等
						dataType:'JSON', //后台返回数据格式
						data:d.field, //提交到后台的数据
						success:function(obj){  //执行成功回调函数，返回一个obj对象
							//执行ajax提交成功后处理代码
							layer.msg(obj.msg)
							parent.table.reload('tblCustomer')
							var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
							parent.layer.close(index); //再执行关闭
						}
					})
				}
				
			    // layer.msg('修改成功')
			    return false; //阻止form提交刷新
			  });
			  
			})
		</script>
	</body>
</html>
